// pages/teacher/my-courses/my-courses.js
import { courses } from '../../../utils/mockData.js'

Page({
  data: {
    courses: courses,
    filterIndex: 0,
    filters: ['全部', '进行中', '未开始', '已结束']
  },
  onLoad() {
    this.loadCourses()
  },
  loadCourses() {
    this.setData({
      courses: courses
    })
  },
  switchFilter(e) {
    const index = e.currentTarget.dataset.index
    this.setData({ filterIndex: index })
    this.loadCourses()
  },
  goToCourseDetail(e) {
    const id = e.currentTarget.dataset.id
    wx.navigateTo({
      url: `/pages/teacher/course-manage/course-manage?id=${id}`
    })
  },
  createCourse() {
    wx.navigateTo({
      url: '/pages/teacher/course-manage/course-manage'
    })
  }
})
